<?xml version="1.0" encoding="UTF-8" ?>

<definitions id="definitions"
             targetNamespace="http://camunda.org/schema/1.0/bpmn20" 
             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:camunda="http://camunda.org/schema/1.0/bpmn">
  
  <process id="vacationRequest" name="Vacation request" isExecutable="true">
  
    <startEvent id="request" camunda:formKey="org/camunda/bpm/engine/test/api/form/util/request.html" />

    <sequenceFlow id="flow1" sourceRef="request" targetRef="handleRequest" />
    
    <userTask id="handleRequest" name="Handle vacation request"
              camunda:formKey="org/camunda/bpm/engine/test/api/form/util/approve.html" >
      <documentation>
        Vacation request by ${employeeName}
      </documentation> 
      <potentialOwner>
        <resourceAssignmentExpression>
          <formalExpression>management</formalExpression>
        </resourceAssignmentExpression>
      </potentialOwner>         
    </userTask>

    <sequenceFlow id="flow2" sourceRef="handleRequest" targetRef="requestApprovedDecision" />
    
    <exclusiveGateway id="requestApprovedDecision" name="Request approved?" />
    
    <sequenceFlow id="flow3" sourceRef="requestApprovedDecision" targetRef="sendApprovalMail">
      <conditionExpression xsi:type="tFormalExpression">${vacationApproved == 'true'}</conditionExpression>
    </sequenceFlow>
    
    <task id="sendApprovalMail" name="Send confirmation e-mail" />
    
    <sequenceFlow id="flow4" sourceRef="sendApprovalMail" targetRef="theEnd1" />
    
    <endEvent id="theEnd1" />
    
    <sequenceFlow id="flow5" sourceRef="requestApprovedDecision" targetRef="adjustVacationRequestTask">
      <conditionExpression xsi:type="tFormalExpression">${vacationApproved == 'false'}</conditionExpression>
    </sequenceFlow>
    
    <userTask id="adjustVacationRequestTask" name="Adjust vacation request" 
              camunda:formKey="org/camunda/bpm/engine/test/api/form/util/adjustRequest.html">
      <documentation>
        Your manager has not approved your vacation request.
      </documentation>
      <humanPerformer>
        <resourceAssignmentExpression>
          <formalExpression>${employeeName}</formalExpression>
        </resourceAssignmentExpression>
      </humanPerformer>  
    </userTask>
     
    <sequenceFlow id="flow6" sourceRef="adjustVacationRequestTask" targetRef="resendRequestDecision" />
    
    <exclusiveGateway id="resendRequestDecision" name="Resend request?" />
    
    <sequenceFlow id="flow7" sourceRef="resendRequestDecision" targetRef="handleRequest">
      <conditionExpression xsi:type="tFormalExpression">${resendRequest == 'true'}</conditionExpression>
    </sequenceFlow>
    
     <sequenceFlow id="flow8" sourceRef="resendRequestDecision" targetRef="theEnd2">
      <conditionExpression xsi:type="tFormalExpression">${resendRequest == 'false'}</conditionExpression>
    </sequenceFlow>
          
    <endEvent id="theEnd2" />
      
  </process>
  
</definitions>
